<?php
  #--------------------------------------------------
  # ALL INCLUDES + STANDARD-VALUES
  #--------------------------------------------------
  include_once("../include/author.php5");
  include_once("../include/config.inc");
  include_once("../include/template.inc");
  include_once("../include/class.db.php5");
  include_once("../include/class.tools.php5");
  $svo = new db("svoptik");
  $tools = new tool();
  
  include_once("../include/global_fix_intern.inc");
  
  #--------------------------------------------------
  # CREATE TEMPLATE
  #--------------------------------------------------
  $t = new Template("templates", "keep");
  $t->set_file(array("page"   => "svoptik_popup.tpl",
                     "member" => "admin_user_details.tpl"));
  #--------------------------------------------------


  #--------------------------------------------------
  # CREATE CONTENT "USER-DETAILS"
  #--------------------------------------------------
  if($usr_priv > 2)
  {
      global $member_id, $member_name, $member_password, $member_conf_pass, $member_email, $member_newsletter, $member_priv, $send;
      $msg = "";
      $content = "";

      if ($send) {
          if (empty($member_name) || empty($member_vname) || empty($member_email) || !ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})",$member_email)) {
              $t->set_var(array("MSG"   => "Bitte &uuml;berpr&uuml;fen Sie Ihre Eingaben!"));
          } else {
              if ($member_newsletter == "on") $member_newsletter = 1;
              else $member_newsletter = 0;

              if (!empty($member_name) && !empty($member_vname) && !empty($member_email) && ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})",$member_email)) {
                  $svo->doSQL("update ".$table['User']." set usr_name       = '".$member_name."',
                                                             usr_vname      = '".$member_vname."',
                                                             usr_email      = '".$member_email."',
                                                             usr_adresse    = '".$member_adresse."',
                                                             usr_plz        = '".$member_plz."',
                                                             usr_ort        = '".$member_ort."',
                                                             usr_tel        = '".$member_tel."',
                                                             usr_priv       = '".$member_priv."',
                                                             usr_mobil      = '".$member_mobil."',
                                                             usr_newsletter = '".$member_newsletter."',
                                                             usr_last_admin = '".$usr_id."'
                                                             where usr_id='".$member_id."';");
              $msg .= "&Auml;nderungen wurden vorgenommen";
              } else $msg .= "&Auml;nderungen konnten nicht gespeichert werden.";
          }
      }
      $user = $svo->readRecordset("select * from ".$table['User']." where usr_id='".$member_id."';");

      $rights = "";
      $priv = array("neuer User","normaler User","Verantwortlicher","Administrator");
      for ($x=0;$x<=3;$x++) {
          if ($user['usr_priv'] == $x) $rights .= "<input type=\"radio\" name=\"member_priv\" value=\"".$x."\" checked>".$priv[$x]."<br>";
          else $rights .= "\n<input type=\"radio\" name=\"member_priv\" value=\"".$x."\">".$priv[$x]."<br>";
      }

      if ($user['usr_newsletter']) $newsletter = " checked";
      else $newsletter = "";

      $t->set_var(array("VORNAME"    => $user['usr_vname'],
                        "NAME"       => $user['usr_name'],
                        "NICK"       => $user['usr_nick'],
                        "EMAIL"      => $user['usr_email'],
                        "ADRESSE"    => $user['usr_adresse'],
                        "PLZ"        => $user['usr_plz'],
                        "ORT"        => $user['usr_ort'],
                        "TEL"        => $user['usr_tel'],
                        "MOBIL"      => $user['usr_mobil'],
                        "PASSWORT"   => $user['usr_passwd'],
                        "ID"         => $user['usr_id'],
                        "RIGHT_ID"   => $user['usr_priv'],
                        "RIGHTS"     => $rights,
                        "NEWSLETTER" => $newsletter,
                        "MSG"        => $msg."<br><br>"));
      $content .= $t->parse("", "member", true);
  } else $content = "
  <script language=\"javascript\">
  <!--
  alert('Du besitzt leider nicht die erforderlichen Rechte,\\num diese Seite anzeigen zu lassen!');
  window.location.replace('index.php5');
  //-->
  </script>
  ";

  #--------------------------------------------------


  #--------------------------------------------------
  # PARSE & OUTPUT
  #--------------------------------------------------
  $t->set_var(array("NAVI"    => "<img src=\"../standard/spacer.gif\" width=\"10\" height=\"20\" border=\"0\" alt=\"\">",
                    "sitenav" => "MEMBERAREA -> USERDETAILS",
                    "content" => $content));

  $t->parse("ALL", "page", true);
  $t->p("ALL");
?>
